You are here: Custom Study Programming > Reference > Classes > StudyData > StudyData Methods > count

count

The count method returns the number of data values inside StudyData object.

Syntax

var count();

Return Value

The method returns a numeric value representing number of data values.

Example

The following demonstrates how to use count() in calculate function.

 

function init()

{

addDataPlot("customSMA");

addParameter("maxPoints", 100);

}

 

function calculate(beginIndex, endIndex)

{

//retrieve StudyData object instance, and if there is available room, insert data into the object

 

var studyData = this.getStudyData("customSMA");

if(studyData != null)

{

//retrieve maximum allowed data points

var maxPoints = parseInt(this.getParameter("maxPoints"));

 

if(maxPoints < studyData.count())

studyData.insert(0);

}

}

 


Copyright © 2006-2009 ActiveTick LLC